<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML><HEAD><TITLE>Man page of XBEE_NETSTART</TITLE>
</HEAD><BODY>
<H1>XBEE_NETSTART</H1>
Section: Linux Programmer's Manual (3)<BR>Updated: 04-Mar-2012<BR><A HREF="#index">Index</A>
<A HREF="../index.html">Return to Main Contents</A><HR>

<A NAME="lbAB">&nbsp;</A>
<H2>NAME</H2>

xbee_netStart, xbee_netvStart, xbee_netStop
<A NAME="lbAC">&nbsp;</A>
<H2>SYNOPSIS</H2>

<B>#include &lt;<A HREF="file:///usr/include/xbee.h">xbee.h</A>&gt;</B>

<P>
<B>xbee_err xbee_netStart(struct xbee *</B><I>xbee</I><B>, int </B><I>port</I><B>, int(*</B><I>clientFilter</I><B>)(struct xbee *xbee, const char *remoteHost));</B>

<P>
<B>xbee_err xbee_netvStart(struct xbee *</B><I>xbee</I><B>, int </B><I>fd</I><B>, int(*</B><I>clientFilter</I><B>)(struct xbee *xbee, const char *remoteHost));</B>

<P>
<B>xbee_err xbee_netStop(struct xbee *</B><I>xbee</I><B>);</B>

<A NAME="lbAD">&nbsp;</A>
<H2>DESCRIPTION</H2>

These functions allow you to start and stop the network interface for libxbee.
<P>
If you use
<B>xbee_netStart</B>()

libxbee will listen on all avaliable interfaces, you can only specify which port to listen on.
<P>
If you use
<B>xbee_netvStart</B>()

you must provide a file descriptor for a socket that has been bound to an interface and port - using
<B><A HREF="../man2/socket.2.html">socket</A></B>(2)

and
<B><A HREF="../man2/bind.2.html">bind</A></B>(2)

- but is not yet listening. 
<P>
For both of these functions, you may specify a
<I>clientFilter</I>

that may decide if the client will be granted access, or denied. If the function returns 0, then the connection will be permitted, otherwise it will be terminated. See the example for more details.
<P>
If you wish to terminate the network interface before calling 
<B><A HREF="../man3/xbee_shutdown.3.html">xbee_shutdown</A></B>(3),

you may use
<B>xbee_netStop</B>().

If you do not call
<B>xbee_netStop</B>()

before
<B><A HREF="../man3/xbee_shutdown.3.html">xbee_shutdown</A></B>(3),

then libxbee will call it for you.
<A NAME="lbAE">&nbsp;</A>
<H3>Return Value</H3>

On success these functions will return XBEE_ENONE, otherwise an error number from
<I>enum xbee_errors</I> (as specified in <I>&lt;<A HREF="file:///usr/include/xbee.h">xbee.h</A>&gt;</I>)

<A NAME="lbAF">&nbsp;</A>
<H2>EXAMPLE</H2>


<PRE>
#include &lt;<A HREF="file:///usr/include/xbee.h">xbee.h</A>&gt;

int myClientFilter(struct xbee *xbee, const char *remoteHost) {
        printf(&quot;Connection request from [%s]\n&quot;, remoteHost);
        return 0; /* return 0 - accept, anything else means deny  */
}

struct xbee *xbee;

/* initialize xbee, using xbee_setup() */

xbee_netStart(xbee, 27015, myClientFilter);

/* use the network interface... */

xbee_netStop(xbee);
</PRE>


<A NAME="lbAG">&nbsp;</A>
<H2>AUTHOR</H2>

Attie Grande &lt;<A HREF="mailto:attie@attie.co.uk">attie@attie.co.uk</A>&gt; 
<A NAME="lbAH">&nbsp;</A>
<H2>SEE ALSO</H2>

<B><A HREF="../man3/libxbee.3.html">libxbee</A></B>(3),

<B><A HREF="../man3/xbee_setup.3.html">xbee_setup</A></B>(3),

<B><A HREF="../man2/socket.2.html">socket</A></B>(2),

<B><A HREF="../man2/bind.2.html">bind</A></B>(2)


<HR>
<A NAME="index">&nbsp;</A><H2>Index</H2>
<DL>
<DT><A HREF="#lbAB">NAME</A><DD>
<DT><A HREF="#lbAC">SYNOPSIS</A><DD>
<DT><A HREF="#lbAD">DESCRIPTION</A><DD>
<DL>
<DT><A HREF="#lbAE">Return Value</A><DD>
</DL>
<DT><A HREF="#lbAF">EXAMPLE</A><DD>
<DT><A HREF="#lbAG">AUTHOR</A><DD>
<DT><A HREF="#lbAH">SEE ALSO</A><DD>
</DL>
<HR>
This document was created by
<A HREF="/cgi-bin/man/man2html">man2html</A>,
using the manual pages.<BR>
Time: 18:19:28 GMT, September 04, 2013
</BODY>
</HTML>
